package com.yl.drug_management.controller;


import com.ruoyi.common.core.web.domain.AjaxResult;
import com.yl.drug_management.pojo.Cron;
import com.yl.drug_management.service.CronService;
import com.yl.drug_management.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TestContestController {

    @Autowired
    CronService cronService;

    @Autowired
    OrderService orderService;

    @GetMapping("/test")
    public String test() {
        return "ok";
    }

    @GetMapping("/getCron")
    public AjaxResult getCron() {
        List<Cron> list = cronService.getAllCron();
        return AjaxResult.success(list);
    }

    @RequestMapping("/addCron")
    public AjaxResult addCron(@RequestParam("sid") int sid,@RequestParam("cron") String cron) {
        System.out.println("sid:"+sid);
        System.out.println("cron:" + cron);
        cronService.addCron(sid,cron);
        return AjaxResult.success();
    }

    @GetMapping("/paysuccess")
    public AjaxResult paySuccess(@RequestParam("sid") int sid,@RequestParam("userId") String userid) {
        orderService.updatePayStatus(sid,userid);
        return AjaxResult.success();
    }
}
